<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>

    <body>
        <script>
            // 为 myCalculator 实现“加减乘除”方法，并支持链式调用。
            var myCalculator = function (init) {
                // console.log(this);
                myCalculator.prototype.init=init
                // this.init = init
                // this.init=init;
                return this

            }
            myCalculator.prototype.plus = function (num) {
                myCalculator.prototype.init*= num;
                return this;
            }
            myCalculator.prototype.equals = function () {
                return myCalculator.prototype.init
            }
            console.log( myCalculator(1).equals());
            // console.log( myCalculator(1).plus(2).equals());
            // console.log( myCalculator(1));
            // console.log(myCalculator(121));


            // 执行结果
            // myCalculator(1).plus(1).times(3).equals() // 6
            // myCalculator(121).plus(1).minus(2).times(3).dividedBy(4).equals() // 90

        </script>
    </body>

    </html>
</body>

</html>